package com.example.aircraftticketingsystemserver.controller;

import com.example.aircraftticketingsystemserver.entity.Notification;
import com.example.aircraftticketingsystemserver.service.INotificationService;
import com.example.aircraftticketingsystemserver.utils.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = {"*","null"})
@RequestMapping("/notice")
public class NotificationController {
    @Resource
    INotificationService notificationService;

    @PostMapping("/addNotice")
    public Result addNotice(@RequestBody Notification notification){
        notificationService.addNotice(notification);
        return Result.ok();
    }

    @PostMapping("/deleteNotice")
    public  Result deleteNotice(@RequestBody List<Integer> notificationIds){
        notificationService.deleteNotice(notificationIds);
        return Result.ok();
    }

    @GetMapping("/getNoticePage")
    public Result getNoticePage(@RequestParam(value = "pageNo")Integer pageNo,
                                @RequestParam(value = "pageSize")Integer pageSize,
                                Integer userId){
        return Result.ok(notificationService.getNoticeByUserId(pageNo, pageSize, userId));
    }
}
